import { createRouter, createWebHistory } from 'vue-router';

const routes = [
  {
    path: '/',
    component: () => import('@/views/layout/index.vue'),
    redirect: '/home',
    children: [
      {
        path: '/home',
        name: 'home',
        component: () => import('@/views/home/index.vue'),
        meta: {
          isKeepAlive: true, // 是否缓存
        },
      },
      // {
      //   path: '/user',
      //   name: 'user',
      //   component: () => import('@/views/users/index.vue'),
      //   meta: {
      //     isKeepAlive: true, // 是否缓存
      //   },
      // },
    ],
  },
  {
    path: '/:pathMatch(.*)*',
    name: '404',
    component: () => import('../views/404/index.vue'),
  },

  {
    path: '/detail',
    name: 'detail',
    component: () => import('@/views/detail/index.vue'),
    meta: {
      isKeepAlive: true, // 是否缓存
    },
  },
  {
    path: '/car',
    name: 'car',
    component: () => import('@/views/car/index.vue'),
    meta: {
      isKeepAlive: true, // 是否缓存
    },
  },
];
const router = createRouter({
  history: createWebHistory(),
  routes: routes,
});
export default router;
